﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BCDto.Common.Business.WebsiteBusinessCategory;
using BCDto.Common.Business.WebsiteBusinessTagcode;
using BCService.Common.Business.WebsiteBusinessIntroduction;
using BCService.Common.Business.WebsiteBusinessTagcode;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace BCTMSRESTful.Controllers.Anonymous
{
    [Route("api/v1/[controller]")]
    [ApiController]
    public class BusinessController : BCTMSRESTfulAPIController
    {
        private readonly IWebsiteBusinessTagcodeService websiteBusinessTagcodeService;
        private readonly IWebsiteBusinessIntroductionService websiteBusinessIntroductionService;

        public BusinessController(IWebsiteBusinessTagcodeService websiteBusinessTagcodeService, IWebsiteBusinessIntroductionService websiteBusinessIntroductionService)
        {
            this.websiteBusinessTagcodeService = websiteBusinessTagcodeService;
            this.websiteBusinessIntroductionService = websiteBusinessIntroductionService;
        }

        /// <summary>
        /// 获取官网业务标记码列表。
        /// </summary>
        /// <response code="200">返回官网业务标记码列表</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(IEnumerable<WebsiteBusinessTagcodeDto>), 200)]
        [AllowAnonymous]
        public IActionResult TagCodes()
        {
            return this.Ok(this.websiteBusinessTagcodeService.GetList());
        }

        /// <summary>
        /// 获取官网业务分类及简介列表。
        /// </summary>
        /// <param name="tagcode">标记码</param>
        /// <response code="200">返回官网业务分类及简介列表</response>
        /// <returns></returns>
        [HttpGet]
        [ProducesResponseType(typeof(IEnumerable<WebsiteBusinessCategoryViewDto>), 200)]
        [AllowAnonymous]
        public IActionResult Get([FromQuery(Name = "tagcode")]string tagcode)
        {
            return this.Ok(this.websiteBusinessIntroductionService.GetList(tagcode));
        }
    }
}
